cd ${work}5_reg_analysis

local ylist		"profits employees investments assets equity inventory purchase_buildings purchase_energy wagebill purchase_opeq credit dividends rent prepayments capital expenditures vrd_exp vrd_imp"
local fe		"IDY"
local w			"c.sales##c.sales##c.sales##c.sales"

use temp\balancesample_idt, clear

eststo clear
local estlist1
local estlist2
local n=1
foreach y of local ylist {

	gen x_`n' = tdcinitiative_1
	lab var x_`n' "`:var lab `y''"
	eststo est`n'_1 : reghdfe `y' x_`n' `w', a(`fe') vce(cl F) nosamp
	local estlist1 `estlist1' est`n'_1
	
	replace x_`n' = treated_1
	eststo est`n'_2 : reghdfe `y' x_`n' `w', a(`fe') vce(cl F) nosamp
	local estlist2 `estlist2' est`n'_2

	local ++n

}

foreach m of numlist 1/2 {
    
	if `m'==1 local x tdcinitiative_1
	if `m'==2 local x treated_1

   	reghdfe `x' `ylist' `w', a(`fe') vce(cl F) nosamp
	local N = e(N)
	testparm `ylist'
	local p = r(p)
 
	eststo stacked_`m' : appendmodels `estlist`m''
	qui estadd scalar N `N'
	qui estadd scalar p `p'	
	
}	
	
esttab stacked_1 stacked_2 using output\table_a3.tex, replace booktabs se label ///
	title("Evicende for Randomness of Outreach Activity") star(* 0.1 ** 0.05 *** 0.01) mtitles(Called Supported) keep(x_*) ///
	stats(N p , labels("Observations" "p-value for joint F-test") fmt(%10.0fc %10.3fc))